﻿using HomagChina.CCHCS.DataTypeModel;
using HomagChina.CCHCS.ViewModels;
using HomagChina.CCHCS.Views;
using HomagGroup.Base.UI;
using HomagGroup.Base.UI.Themes.Resources;
using System.Collections.ObjectModel;
using static HomagChina.CCHCS.ProcessResourceInternal;
using static HomagChina.CCHCS.Utility;

namespace HomagChina.CCHCS.Router
{
    public class JobListRoute : NotifyPropertyChangedBase
    {
        public RouterItemDataModel JobListRouteModel { get; set; }

        public JobListRoute()
        {
            var model = new JobListViewModel();
            var userControl = GetUserControlInstance("JobList") as JobList;
            model.RequestScrollPositionSave += userControl.ViewModel_RequestScrollPositionSave;
            model.RequestScrollPositionRestore += userControl.ViewModel_RequestScrollPositionRestore;
            JobListRouteModel = new RouterItemDataModel()
            {
                ID = "JobList",
                viewLabel = GetLocalText("Joblist"),
                viewName = "Joblist",
                viewModelName = "JobListViewModel",
                ViewModel = model,
                keepalive = true,
                userControl = userControl,
                Image = null,
                functionKeyBarItems = new ObservableCollection<FunctionKeyBarItemDataModel>{
                    //new FunctionKeyBarItemDataModel() {
                    //    Header =  GetLocalText("Exit"),
                    //    Position = 12,
                    //    Icon = GetIconBrush(Icon.Close, ImageDecoration.Circle),
                    //    Command = new RelayCommand(() => { Application.Current.Shutdown(); })
                    //},
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("MoveTop"),
                        Position = 11,
                        Icon = GetResourceBrush("JobMove"),
                        Command= new RelayCommand(model.HandleMoveTop)
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Cancel"),
                        Position = 10,
                        Icon = GetResourceBrush("JobCancel"),
                        Command= new RelayCommand(model.HandleJobCancel)
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Delete"),
                        Position = 9,
                        Icon =GetIconBrush(Icon.Delete),
                        Command= new RelayCommand(model.HandleJobDelete)
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Manual Infeed"),
                        Position = 7,
                        Icon =GetResourceBrush("Manual Infeed"),
                        Command= new RelayCommand(model.HandleOpenManualInfeed)
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Manual Outfeed"),
                        Position = 6,
                        Icon =GetResourceBrush("Manual Outfeed"),
                        Command= new RelayCommand(model.HandleOpenManualOutfeed)
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Schedule Job"),
                        Position = 4,
                        Icon = GetResourceBrush("JobSchedule"),
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Job Import"),
                        Position = 3,
                        Icon = GetResourceBrush("JobImport"),
                        Command= new RelayCommand(model.HandleOpenJobImport)
                    },
                    new FunctionKeyBarItemDataModel()
                    {
                        Header =  GetLocalText("Info"),
                        Position = 1,
                        Icon = GetIconBrush(Icon.Information, imageDecoration: ImageDecoration.Circle),
                        //Command = new RelayCommand(() => { new Utility().OpenInformationCommand(Handle_Search.GetSystemInfoMation()); })
                    }
                }
            };
            JobListRouteModel.userControl.DataContext = model;
        }
    }
}